import axios from 'axios'

const service = axios.create({
    timeout: 3000
})
// 配置请求的跟路径
// service.defaults.baseURL = 'http://39.107.112.127:8082/'

// 配置请求的跟路径
service.defaults.baseURL = 'http://39.107.112.127:8082/'
// service.defaults.headers.put['Content-Type'] = 'application/json;charset=UTF-8'

// service.defaults.headers['Access-Control-Allow-Origin']='*'
service.interceptors.request.use(
    config => {
        config.headers.common = {
            'Access-Control-Allow-Origin': '*'
        }
        const token = window.sessionStorage.getItem('token')
        if (token) {
          config.headers.token = token
        }
        return config
    },
    error => {
        console.log('请求拦截器:', error)
    }
)

// 响应拦截器
service.interceptors.response.use(
    response =>{
        return response
    },
    error => {
        console.log('请求拦截器:', error)
    }
)
export default service